package in.muton.edushare.pages.group;

import in.muton.edushare.components.alertpanel.AlertPanel;
import in.muton.edushare.components.messaging.recievepanel.IncomingMessagesPanel;
import in.muton.edushare.components.messaging.sendpanel.ActionPanel;
import in.muton.edushare.components.tasks.requests.RequestPanel;
import in.muton.edushare.url.URLLoader;

import org.apache.wicket.PageParameters;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.markup.html.panel.EmptyPanel;

import com.edushare.common.constants.ApplicationConstants;
import com.edushare.common.constants.URLConstants;

public class GroupNews extends GroupBase {

	public GroupNews(PageParameters params) {
		super(params);
		if(!getLoggedInUser().isGroupMember(super.groupModel.getObject())){
			throw new RestartResponseException(URLLoader.getPageClass(URLConstants.UNAUTHORIZED_PATH));
		}
		
		add(new ActionPanel("actionPanel", super.getGroupModel().getObject(), this));
		add(new IncomingMessagesPanel("msgPanel", super.getGroupModel().getObject()));
		add(new AlertPanel("alertPanel", super.getGroupModel()));
		if(getLoggedInUser().isGroupAdmin(super.groupModel.getObject()))
			add(new RequestPanel("requestPanel", super.getGroupModel(), this));
		else
			add(new EmptyPanel("requestPanel"));
	}

	@Override
	protected String getActivePage() {
		return "groupNews";
	}

	@Override
	public String getPageTitle() {
		return super.getGroupModel().getObject().getGroupName() + " | " + ApplicationConstants.APPLICATION_NAME;
	}

}
